<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<meta name="format-detection" content="telephone=no,email=no,adress=no" />
<META HTTP-EQUIV="luxiaoqing" CONTENT="no-cache">

<link rel="stylesheet"  type="text/css"  href="css/login.css" ><!-- 通用CSS -->
<script src="js/jquery-1.11.3.js" type="text/javascript"></script>
<link rel="stylesheet"  type="text/css"  href="css/all.css" >
<link rel="stylesheet"  type="text/css"  href="css/business.css" ><!-- 商家CSS -->

<title></title>
</head>

<body>
<div class="business_top">
	<div class="business_top-middle">
	    	<div class="business_top-logo">
	           <img src="images/logo02.png"/>
        </div>
    </div>
    
</div>
<div class="clear4"></div>

<!--中间-->
<div class="business_register-center">
	<div class="business_register-center-middle">
    	<div class="clear1"></div>
        
    	<div class="business_register-center-middle-title">
        	<span>
            	商家注册
            </span>
            
            <span class="fanhui">
            	<a href="<c:url value="/toMerchantLogin.do"/>">已有帐号，立即登陆</a>
            </span>
        </div>
        
        <div class="clear3"></div>
        <div class="business_register-center-middle-from">
        		<div class="business_register-center-middle-form-number">
            		<div class="business_login-center-middle-form-number-input no3">
	                	<input type="text" id="userName" name="new_phone" placeholder="手机号" title="请输入有效的手机" data-toggle="tooltip" />
	            </div>
           </div>
            <div class="clear1"></div>
            
            <div class="business_register-center-middle-form-verification">
            		<div class="business_register-center-middle-form-verification-text no3">
               	 	<input type="text" id="phone_code" name='phone_code' placeholder="请输入短信验证码" required />
                </div>
                
                <div class="business_register-center-middle-form-verification-button">
              	  	<input type="button" id="btn" value="获取验证码" />
                </div>
            </div>
            
            <div class="clear3"></div>
            
            <div class="business_register-center-middle-form-password">
                <div class="business_login-center-middle-form-password-input no3">                    
                		<input type="password" id="password" name="password"  placeholder="密码" title="请输入6-16位密码，字母区分大小写" data-toggle="tooltip" />
			   </div>
		   </div>
            
            <div class="clear"></div>
            
            <div class="clear1"></div>
            
            <div class="business_register-center-middle-form-checkbox">
            	<div class="business_register-center-middle-form-checkbox-input">
                	<input type="checkbox" name='agree_contract' required checked/>
                </div>
                
                <div class="business_register-center-middle-form-checkbox-span">
                	<span>
                    	<a href="http://www.69mark.com/shop_agreement.html">我已阅读并同意使用条款</a>
                    </span>
                </div>
                
                <div class="clear"></div>
            </div>
            
            <div class="clear"></div>
            
            <div class="business_register-center-middle-form-sub">
            	<input type="button" value="注册" onclick="toRegister()"/>
            </div>
            
            <div class="clear3"></div>
        </div>
    </div>
    <div class="clear2"></div>
</div>
<!--中间end-->





<div class="clear2"></div>

<!--底部-->
<div class="business_foot">
	<jsp:include page="../lbi/merFooter.jsp"></jsp:include>
</div>
<!--底部end-->

<div class="clear8"></div>

<script type="text/javascript">

var _serviceURL='/69mark';//必须设置

	$('#btn').click(function(){
		
		var btn = $(this);
        btn.attr("disabled", "disabled").addClass("dis");
        var time = 60000;
        var time2 = setInterval(function() {
            time -= 1000;
            if ((time / 1000) == 0) {
                btn.val("重新发送");
                window.clearInterval(time2);
                btn.removeAttr("disabled").removeClass("dis");
            }
            else {
                btn.val("重新发送(" + time / 1000 + ")");
            }

        }, 1000);
        
        var url = _serviceURL+"/toSmsSend.do";
        var regPhone = /^1([3578]\d|4[57])\d{8}$/;
		var userName = $("#userName").val();
		if (userName !=null &&  regPhone.test( userName )) {
			$.post(url,{'userName':userName},function(data){
				if (data == "1") {
				}else if (data == "2") {
					alert('该账号已被注册');
					btn.val("重新发送");
	                window.clearInterval(time2);
	                btn.removeAttr("disabled").removeClass("dis");
				}else{
					alert('短信发送失败。');
					btn.val("重新发送");
		            window.clearInterval(time2);
		            btn.removeAttr("disabled").removeClass("dis");
				}
			})
		}else {
			alert("填写正确手机号");
			btn.val("重新发送");
            window.clearInterval(time2);
            btn.removeAttr("disabled").removeClass("dis");
		}
})

function toRegister(){
	var userName = $("#userName").val();
	var phone_code = $("#phone_code").val();
	var password = $("#password").val();
	
	$.ajax({
		  type : "POST",
			url : _serviceURL+"/toRegisterSave.do",
			cache : false,
			data : "userName="+userName+"&phone_code="+phone_code+"&password="+password,
			dataType : 'json',
			success : function(data) {
				if (data == 1) {
					window.location.href=_serviceURL+"/toRegister2.do";
				}else if (data == 2){
					alert('该账号已被注册');
				}else{
					alert('验证码错误');
				}
			}
	  })
	
}
	

</script>
</body>
</html>

